package lk.icta.core.entity;

import lk.icta.common.AppConstants;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @author Mahesha Kalpanie
 * @author Duminda Dharmakeerthi
 */
@Entity
@Table(schema = "COMMON_RAIL")
@NamedQueries({
        @NamedQuery(
                name = "getAllLocalAuthorities",
                query = "SELECT lat FROM LocalAuthorityType lat"
        )
})
public class LocalAuthorityType implements Serializable {
    /**
     * A system generated unique key
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    /**
     * The Name of the Local Authority
     */
    @Column(nullable = false, unique = true, updatable = false)
    private String siName;
    @Column(nullable = false, unique = true, updatable = false)
    private String enName;
    @Column(nullable = false, unique = true, updatable = false)
    private String taName;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getSiName() {
        return siName;
    }

    public void setSiName(String siName) {
        this.siName = siName;
    }

    public String getEnName() {
        return enName;
    }

    public void setEnName(String enName) {
        this.enName = enName;
    }

    public String getTaName() {
        return taName;
    }

    public void setTaName(String taName) {
        this.taName = taName;
    }

    public String getLocalAuthorityNameByLanguage(String language) {
        String localAuthorityName = "";
        if (AppConstants.ENGLISH.equals(language)) {
            localAuthorityName = getEnName();
        } else if (AppConstants.SINHALA.equals(language)) {
            localAuthorityName = getSiName();
        } else if (AppConstants.TAMIL.equals(language)) {
            localAuthorityName = getTaName();
        }

        return localAuthorityName;
    }
}
